package org.gexperiments.graph;

public class Link {
	private String id;

	private Node aEnd;
	private Node zEnd;
	private double weight;

	public Link() {

	}

	public Link(String id, Node aEnd, Node zEnd, double weight) {
		super();
		this.id = id;
		this.aEnd = aEnd;
		this.zEnd = zEnd;
		this.weight = weight;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Node getaEnd() {
		return aEnd;
	}

	public void setaEnd(Node aEnd) {
		this.aEnd = aEnd;
	}

	public Node getzEnd() {
		return zEnd;
	}

	public void setzEnd(Node zEnd) {
		this.zEnd = zEnd;
	}

	public double getWeight() {
		return weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((aEnd == null) ? 0 : aEnd.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		long temp;
		temp = Double.doubleToLongBits(weight);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((zEnd == null) ? 0 : zEnd.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Link other = (Link) obj;
		if (aEnd == null) {
			if (other.aEnd != null)
				return false;
		} else if (!aEnd.equals(other.aEnd))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (Double.doubleToLongBits(weight) != Double.doubleToLongBits(other.weight))
			return false;
		if (zEnd == null) {
			if (other.zEnd != null)
				return false;
		} else if (!zEnd.equals(other.zEnd))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return String.valueOf(id);
	}

}